import { _decorator, Component, Sprite } from 'cc';
import { BottomBannerAd } from '../platform/ad/BottomBannerAd';
import { MatrixCustomLeftAd } from '../platform/ad/MatrixCustomLeftAd';
import { MatrixCustomRightAd } from '../platform/ad/MatrixCustomRightAd';
import { ResourceManager } from '../framework/ResourceManager';
import { NetSoundManager } from '../framework/SoundManager';
import { Databus } from '../core/Databus';
const { ccclass, property } = _decorator;
const databus = Databus.Instance();
@ccclass('RoomPage')
export class RoomPage extends Component {
  onLoad(): void {
    this.loadBallResource();
  }
  start() {
    BottomBannerAd.Instance().hide();
    MatrixCustomLeftAd.Instance().hide();
    MatrixCustomRightAd.Instance().hide();
    if (databus.gameSetting.musicOn === 1) {
      NetSoundManager.Instance().playBgMusic();
    }
  }
  update(deltaTime: number) {
  }
  public loadBallResource() {
    const ballImages = this.node.getChildByName('OperationCanvas').getChildByName('BallImages');
    ResourceManager.Instance().setSpriteFrame(`BallSphere1`, ballImages.getChildByName('BallSphere1').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere2`, ballImages.getChildByName('BallSphere2').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere3`, ballImages.getChildByName('BallSphere3').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere4`, ballImages.getChildByName('BallSphere4').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere5`, ballImages.getChildByName('BallSphere5').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere6`, ballImages.getChildByName('BallSphere6').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere7`, ballImages.getChildByName('BallSphere7').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere8`, ballImages.getChildByName('BallSphere8').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere9`, ballImages.getChildByName('BallSphere9').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere10`, ballImages.getChildByName('BallSphere10').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere11`, ballImages.getChildByName('BallSphere11').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere12`, ballImages.getChildByName('BallSphere12').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere13`, ballImages.getChildByName('BallSphere13').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere14`, ballImages.getChildByName('BallSphere14').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphere15`, ballImages.getChildByName('BallSphere15').getComponent(Sprite).spriteFrame);
    
    ResourceManager.Instance().setSpriteFrame(`BallSphereBlack`, ballImages.getChildByName('BallSphereBlack').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSpherePink`, ballImages.getChildByName('BallSpherePink').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphereBlue`, ballImages.getChildByName('BallSphereBlue').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphereCoffee`, ballImages.getChildByName('BallSphereCoffee').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphereGreen`, ballImages.getChildByName('BallSphereGreen').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphereYellow`, ballImages.getChildByName('BallSphereYellow').getComponent(Sprite).spriteFrame);
    ResourceManager.Instance().setSpriteFrame(`BallSphereRed`, ballImages.getChildByName('BallSphereRed').getComponent(Sprite).spriteFrame);
  }
}